package main

import "fmt"

//接口实现
type USBer interface {
	Read()
	Write()
}

//创建usb对象
type usb struct {
	id    int
	name  string
	speed float32
}

type mobile struct {
	usb
	call string
}

type udisk struct {
	usb
}

func (m *mobile) Read() {
	fmt.Printf("%s正在读取数据\n",m.name)
}

func (m *mobile) Write() {
	fmt.Printf("%s正在写入数据\n",m.name)
}

func (u *udisk) Read() {
	fmt.Printf("%s正在读取数据\n",u.name)
}

func (u *udisk) Write() {
	fmt.Printf("%s正在写入数据\n",u.name)
}

func Read(i USBer) {
	i.Read()
}

func Write(i USBer) {
	i.Write()
}

func UsDev(i USBer)  {
	i.Read()
	i.Write()
}

func main() {
	var h USBer
	h = &mobile{usb{1, "小米6", 1.06}, "yuanlj"}
	Read(h)
	Write(h)

	h1 := &udisk{usb{2, "方正U盘", 1}}
	Read(h1)
	Write(h1)
	h1.Read()

	UsDev(h)


}
